@extends('layouts.system')

@section('css')
    <style type="text/css">
        .btnDiv {
            margin-right: 25px;
            float: left;
        }

        .btnDiv button {
            width: 90px;
            border-radius: 5px;
            margin: 5px;
        }

        .tableDiv {
            padding: 20px 20px 50px 20px;
            background-color: #d7d7d7;
            width: 700px;
            text-align: center;
        }

        .tableDiv table {
            width: 400px;
        }

        .tableDiv table tr {
            background-color: #fff;
            text-align: center;
        }

        .tableDiv table th {
            text-align: center;
        }

        @media (max-width: 768px) {
            .tableDiv {
                width: 100%;
            }

            .tableDiv table {
                width: 100%;
            }
        }

    </style>
@endsection

@section('content')
    <div id="cl-wrapper" class="fixed-menu">

        <div class="container-fluid" id="pcont">
            <div class="col-md-12" style="padding-right: 0;">
                <div class="block-flat">
                    <div class="header">
                        <div class="pull-left">
                            <p class="jb_underline">后台管理&#62;&#62;权限功能</p>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="content">
                        <div class="btnDiv">
                            <div>
                                <button type="button" class="btn btn-default" onclick="myPower()">我的权限</button>
                            </div>
                            @if(in_array($auth['auth'],['group_a','group_b','group_c']))
                                <div>
                                    <button type="button" class="btn btn-default" onclick="sendMsg()">群发消息</button>
                                </div>
                                <div>
                                    <button type="button" class="btn btn-default" onclick="msgTrigger()">消息触发</button>
                                </div>
                            @endif
                        </div>

                        <div style="float: left;">
                            <div>
                                <p>当前用户组：<span style="color:#000;">{{$auth['group_name']}}</span></p>
                            </div>
                            <div class="tableDiv">
                                <table class="table-bordered">
                                    <thead>
                                    <tr>
                                        <th>权限</th>
                                        <th>管理组A</th>
                                        <th>管理组B</th>
                                        <th>管理组C</th>
                                        <th>企业组D</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>发布任务</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}"/>
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}"/>
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}"/>
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>修改任务</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}"/>
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}"/>
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>审核任务</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>批准任务</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>批准任务</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>处理提现</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>封禁用户</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>发送消息</td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/yes.gif')}}">
                                        </td>
                                        <td>
                                            <img src="{{ URL::asset('/system/assets/img/no.gif')}}">
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript">

      function sendMsg() {
        window.location.href = '/admin/manager/sendMsg';
      }
      function msgTrigger() {
        window.location.href = '/admin/manager/msgTrigger';
      }
      function myPower() {
        window.location.href = '/admin/manager/myPower';
      }

      Vue.use(VueResource)
      var vm = new Vue({
        el: '#pcont',
        data: {
          current: 1,
          total: 0,
          type: '',
          keyword: '',
          labels: {},
          states: {},
          lists: {}
        },
        created: function () {
          getLists(this);
        },
        methods: {
          changePage: function (current) {
            this._data.current = current
            getLists(this);
          },
          search: function () {
            this._data.current = 1;
            getLists(this);
          },
          changeType: function () {
            this._data.keyword = ''
          }
        }
      })

      function getLists(_vm) {
        var params = {
          current: _vm._data.current
        }
        var conditions = {
          type: _vm._data.type,
          keyword: _vm._data.keyword
        }
        params = $.extend(params, conditions)
        _vm.$http.get('/admin/task/getLists', {params: params})
          .then(function (response) {
            var json = response.body;
            console.log('json:')
            console.log(json)
            if (json.state == 1) {
              _vm._data.lists = json.data.lists;
              _vm._data.total = json.data.total;
              _vm._data.labels = json.data.labels;
              _vm._data.states = json.data.states;
            }
            console.log('data:')
            console.log(_vm._data)

          })
          .catch(function (response) {
            console.log(response)
          })
      }

    </script>
@endsection